package com.example.gateway.balancer;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.loadbalancer.annotation.LoadBalancerClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.reactive.function.client.WebClient;

/**
 * @author  谢飞机
 * @date    2021-08-28
 * 可以根据不同的@LoadBalancerClient(value = "ws-server", configuration = CustomLoadBalancerConfiguration.class)
 * 配置不同的负载均衡策略
 */
@Configuration
@LoadBalancerClient(value = "ws-server", configuration = CustomLoadBalancerConfiguration.class)
public class CustomConfiguration {

    @Bean
    @LoadBalanced
    public WebClient.Builder loadBalancedWebClientBuilder() {
        return WebClient.builder();
    }

}